package Objects;

import org.newdawn.slick.Color;
import org.newdawn.slick.geom.Shape;

public abstract class Body {
		public float CMX, CMY;
		public float mass;
		public float COR;
		public float velocityX;
		public float velocityY;
		public float accelerationX;
		public float accelerationY;
		public float angle;
		public float angularVelocity;
		public float momentOfInertia;
		public Color color;
		public Shape shape;
		
		public float colx;
		public float coly;
		
		public float forceX;
		public float forceY;
		public float epsilon;
		
		
		Body(float mass, float velocityX, float velocityY, float angle,float angularVelocity, float forceX, float forceY, float epsilon){
			this.mass=mass;
			this.velocityX=velocityX/6;
			this.velocityY=velocityY/6;
			this.accelerationX=0;//accelerationX/360;
			this.accelerationY=0;//accelerationY/360;
			this.angle=angle;
			this.angularVelocity=angularVelocity/6;
			this.forceX=forceX;
			this.forceY=(forceY+mass*10)/360;
			this.epsilon=epsilon;
			this.COR=1;

			
		}
		Body(float mass){
			this.mass=mass;
			this.velocityX=0;
			this.velocityY=0;
			this.accelerationX=0;
			this.accelerationY=0;
			this.angle=0;
			this.angularVelocity=0;
			this.forceX=0;
			this.forceY=mass*10/360;
			this.epsilon=0;
			this.COR=1;

		}
		
		Body(Body b){
			this.mass=b.mass;
			this.velocityX=b.velocityX;
			this.velocityY=b.velocityY;
			this.accelerationX=b.accelerationX;
			this.accelerationY=b.accelerationY;
			this.angle=b.angle;
			this.angularVelocity=b.angularVelocity;
			this.forceX=b.forceX;
			this.forceY=b.forceY;
			this.epsilon=b.epsilon;
			this.COR=b.COR;
		}
		
		public void resetColXY(){
			colx=0;
			coly=0;
		}
		
		public void setX(float newX){
			this.shape.setCenterX(newX);
		}
		
		public void setY(float newY){
			this.shape.setCenterY(newY);
		}
		
		public float getX(){
			return this.shape.getCenterX();
		}
		
		public float getY(){
			return this.shape.getCenterY();
		}
		
		public void setVx(float newVx){
			this.velocityX=newVx/6;
		}
		
		public void setVy(float newVy){
			this.velocityY=newVy/6;
		}
		
		public void setAx(float newAx){
			this.accelerationX=newAx/360;
		}
		
		public void setAy(float newAy){
			this.accelerationY=newAy/360;
		}
		
		public void setAngularVelocity(float newOmega){
			this.angularVelocity=newOmega/6;
		}
		
		public float getVx(){
			return this.velocityX*6;
		}
		
		public float getVy(){
			return this.velocityY*6;
		}
		
		public float getAx(){
			return this.accelerationX*360;
		}
		
		public float getAy(){
			return this.accelerationY*360;
		}
		
		public float getAngularVelocity(){
			return this.angularVelocity*6;
		}
		
		public abstract float[] getSupportingPoint(float [] u);

		
//		public float[] findNormal(float pX, float pY){
//			//funkcja wirtualna
//			return null;
//		}
		
}